package com.fzn.spring5.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @program: spring5_txdemo1
 * 描述：
 * @author: fzn
 * @create: 2022-02-27 17:35
 **/
@Repository
public class UserDaoImpl implements UserDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    /**
     *  lucy 转账给 mary
     */
    @Override
    public void reduceMoney() {
        String sql = "update t_account set money=money-? where username=?";
        int lucy = jdbcTemplate.update(sql, "100", "lucy");
    }

    @Override
    public void addMoney() {
        String sql = "update t_account set money=money+? where username=?";
        int lucy = jdbcTemplate.update(sql, "100", "mary");
    }


}